package com.lanchetech.dao;

import com.lanchetech.bean.request.*;import com.lanchetech.bean.response.PartnerResp;import com.lanchetech.bean.vo.*;import com.lanchetech.entity.Identity;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.math.BigDecimal;import java.util.Date;import java.util.List;

@Mapper
public interface IdentityMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Identity record);

    int insertSelective(Identity record);

    Identity selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Identity record);

    int updateByPrimaryKey(Identity record);

    Identity findOneByUserId(@Param("userId") Long userId);

    List<IdentitySimpleVO> findAllMemberForDividends(Date now);

    List<IdentitySimpleVO> findAllPartnerForDividends(Date now);

    List<IdentitySimpleVO> findAllShareholderForDividends();

    List<IdentitySimpleVO> findAllByLevelOver(@Param("level") Integer level);

    List<IdentitySimpleVO> findAllSingleShopDividends(@Param("singleShop") Long singleShop);

    int updateLevelById(@Param("updatedLevel") Integer updatedLevel, @Param("id") Long id);

    int updateLevelByUserId(@Param("updatedLevel") Integer updatedLevel, @Param("userId") Long userId);

    int updateLevelAndShareholderLevelByUserId(@Param("updatedLevel") Integer updatedLevel, @Param("updatedShareholderLevel") Integer updatedShareholderLevel, @Param("userId") Long userId);

    List<IdentityVO> findAllPage(IdentityReq req);

    Integer findLevelByUserId(@Param("userId") Long userId);

    NumberByTypeVO getNumber(ListByTimeReq req);

    List<UserSimpleVO> getBuyerList(@Param("level") Integer level);

    Long selectMaxSingleShop();

    Identity selectOneByUserId(@Param("userId") Long userId);

    List<AvgPromotionIncomeVO> getNumberByPartnerLevel(Date date);

    List<AvgPromotionIncomeVO> getNumberByMemberLevel(Date date);

    List<AvgPromotionIncomeVO> getNumberByShareholderListLevel();

    Integer getTotalShareholderOrderAmount(@Param("level") Integer level);

    Integer getTotalMemberOrderAmount(@Param("level") Integer level);

    Integer getTotalPartnerOrderAmount(@Param("level") Integer level);

    int updateDirectorByUserId(@Param("updatedDirector") Byte updatedDirector, @Param("userId") Long userId);

    int updateTeacherLevelById(@Param("updatedTeacherLevel") Byte updatedTeacherLevel, @Param("id") Long id);

    int updateDirectorAndPartnerAccountByUserId(@Param("updatedDirector") Byte updatedDirector, @Param("updatedPartnerAccount") Integer updatedPartnerAccount, @Param("userId") Long userId);

    List<IdentityVO> findAllTeacher(IdentityReq req);

    int reduceAreaAccount(Long id);

    int cancelAnchor(@Param("updatedAnchorLevel") Byte updatedAnchorLevel, @Param("userId") Long userId);

    int updateRecommendLevelById(@Param("updatedRecommendLevel") int updatedRecommendLevel, @Param("id") Long id);

    Long countByDirector(@Param("director") Byte director);

    int updateMemberLevelAndMemberStateByUserId(@Param("updatedMemberLevel") Integer updatedMemberLevel, @Param("updatedMemberState") Byte updatedMemberState, @Param("userId") Long userId);

    Identity findOneTopByShareholderLevelAndId(@Param("level") Integer level, @Param("id") Long id, @Param("userId") Long userId);

    List<Identity> findAllStaticDividendMember(@Param("type") Byte type, @Param("memberState") Byte memberState, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    List<Identity> findAllStaticDividendPartner(@Param("type") Byte type, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    List<Identity> findAllStaticDividendShareholder(@Param("type") Byte type, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    int updateStaticDividendById(@Param("updatedStaticDividend") BigDecimal updatedStaticDividend, @Param("id") Long id);

    Long sumStaticDividendMember(@Param("type") Byte type, @Param("memberState") Byte memberState, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    Long sumStaticDividendPartner(@Param("type") Byte type, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    Long sumStaticDividendShareholder(@Param("type") Byte type, @Param("staticDividend") BigDecimal staticDividend, @Param("expireTime") Date expireTime);

    Long countByMemberLevel(@Param("level") Integer level, @Param("date") Date date);

    List<Identity> findAllByDirector(@Param("director") Byte director);

    List<DividendMemberVO> findAllDividendMember(TimeRangeReq req);

    List<DividendMemberVO> findAllMemberDividendMember(TimeRangeReq req);

    int updateShareholderStateByUserId(@Param("updatedShareholderState") Byte updatedShareholderState, @Param("userId") Long userId);

    List<DividendItemVO> findAllByDividendPage(DividendPageReq req);

    List<IdentitySimpleVO> findAllShareholderCompanyForDividends(Date date);

    List<Identity> findAllByWelfareGreaterThan(@Param("minWelfare") BigDecimal minWelfare);

    int updateWelfareAndUpdateAtById(@Param("updatedWelfare") BigDecimal updatedWelfare, @Param("updatedUpdateAt") Date updatedUpdateAt, @Param("id") Long id);

    int updateMemberAccountAndUpdateAtByUserId(@Param("updatedMemberAccount") Integer updatedMemberAccount, @Param("updatedUpdateAt") Date updatedUpdateAt, @Param("userId") Long userId);

    int addMemberAccountAndUpdateAtByUserId(@Param("addMemberAccount") Integer addMemberAccount, @Param("updatedUpdateAt") Date updatedUpdateAt, @Param("userId") Long userId);

    List<PartnerResp> findAllPartnerPage(PartnerReq req);

    int updateInviteCountAndInviteRewardLevelAndUpdateAtById(@Param("updatedInviteCount") Integer updatedInviteCount, @Param("updatedInviteRewardLevel") Integer updatedInviteRewardLevel, @Param("updatedUpdateAt") Date updatedUpdateAt, @Param("id") Long id);

    int updateNewZoneBuyAndUpdateAtByUserId(@Param("updatedNewZoneBuy")Byte updatedNewZoneBuy,@Param("updatedUpdateAt")Date updatedUpdateAt,@Param("userId")Long userId);

    int updateMemberExpireTimeAndUpdateAtByUserId(@Param("updatedMemberExpireTime")Date updatedMemberExpireTime,@Param("updatedUpdateAt")Date updatedUpdateAt,@Param("userId")Long userId);

    Byte findMaxNewZoneByUserIds(@Param("list") List<Long> userIds);
}